package com.ruoyi.hr.service.impl.bginfo;


import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.mapper.bginfo.BgProjectMapper;
import com.ruoyi.hr.service.bginfo.BgProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class BgProjectServiceImpl implements BgProjectService {

    @Autowired
    BgProjectMapper bgProjectMapper;

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> findDataList(Map map, Authority authority) {
        return bgProjectMapper.findDataList(map, authority);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> findDataById(String id) {
        return bgProjectMapper.findDataById(id);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int edit(Map map) {
        return bgProjectMapper.edit(map);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int remove(String ids) {
        String[] idSplit = ids.split(",");
        int num = 0;
        for (String id : idSplit) {
            num += bgProjectMapper.remove(id);
        }
        return num;
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int add(Map map) {
        return bgProjectMapper.add(map);
    }
}
